home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / CPAL.ZIP;1 / PALUSER.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-21  |  6.3 KB  |  214 lines

  1. #ifndef PALUSER_HPP
  2. #define PALUSER_HPP
  3.  
  4. #ifndef NO_TYPES
  5. #define bool            int
  6. #define i16             short
  7. #define u16    unsigned short
  8. #define i32             long
  9. #define u32    unsigned long
  10. #endif
  11.  
  12.  
  13. #ifndef EXPPLUS
  14. #define EXPPLUS   _loadds _export pascal     // C++ autoexports
  15. #endif
  16.  
  17. #ifndef _EXPORT 
  18. #define _EXPORT _export
  19. #endif
  20.  
  21. class _EXPORT   palDatum;
  22. class _EXPORT   palAnyType;
  23.  
  24. class _EXPORT   palTime;
  25. class _EXPORT   palDateTime;
  26. class _EXPORT   palDate;
  27.  
  28. class _EXPORT   palLogical;
  29. class _EXPORT   palInteger;
  30. class _EXPORT   palLongInt;
  31. class _EXPORT   palNumber;
  32. class _EXPORT   palMoney;
  33.  
  34. class _EXPORT   palAnnn;
  35.  
  36. class _EXPORT   palReference;
  37. class _EXPORT   palArray;
  38. class _EXPORT   palDynArray;
  39. class _EXPORT   palRecord;
  40.  
  41.  
  42. //
  43. //  OPAL Language mapping of internal data types
  44. //
  45.  
  46. #define AnyType  palDatum    *
  47.  
  48. #define Time     palTime     *
  49. #define DateTime palDateTime *
  50. #define Date     palDate      *
  51.  
  52. #define Logical  palLogical  *
  53. #define SmallInt palInteger  *
  54. #define LongInt  palLongInt  *
  55. #define Number   palNumber      *
  56. #define Money    palMoney      *
  57.  
  58. #define String   palAnnn      *
  59.  
  60. #define UIObject palDatum      *
  61.  
  62. #define Array    palArray        *
  63. #define DynArray palDynArray    *
  64. #define Record   palRecord        *
  65.  
  66.  
  67.  
  68. //
  69. // Structures used for setting and retrieve Date, Time, and
  70. // DateType data types.
  71. //
  72.  
  73. typedef struct pxTime
  74. {
  75.     unsigned short    hour;
  76.     unsigned short    minute;
  77.     unsigned short    secs;
  78.     unsigned short    millisecs;
  79. }  pxTime;
  80.  
  81. typedef struct pxDate
  82. {
  83.     unsigned short    year;
  84.     unsigned short    month;
  85.     unsigned short    day;
  86. }  pxDate;
  87.  
  88. typedef struct pxDateTime
  89. {
  90.     pxDate  date;
  91.     pxTime  time;
  92. }  pxDateTime;
  93.  
  94.  
  95. //
  96. //  Testing for isAssigned and isBlank. 
  97. //
  98.  
  99. bool EXPPLUS pxIsAssigned(AnyType data);
  100. bool EXPPLUS pxIsBlank(AnyType data);
  101.  
  102. //
  103. // Retrieving the OPAL value and placing the result in the supplied
  104. // pointer. A conversion is tried if the types do not match. For
  105. // example if you call pxGetValue(AnyType sm, int * pSm) and the
  106. // ObjectPal data type is really a String. We will assume that
  107. // string really is something like "3" and try to do a convertion.
  108. // The returned boolean indicates the success or failure of the
  109. // operation. The location pointer to by pSm (or other respective pointer)
  110. // is not modified if a failure occured (ie FALSE is returned).
  111. //
  112.  
  113. bool EXPPLUS pxGetValue(AnyType sm , int * pSm);
  114. bool EXPPLUS pxGetValue(AnyType li , long * pLi);
  115. bool EXPPLUS pxGetValue(AnyType nu , long double * pNu);
  116. bool EXPPLUS pxGetValue(AnyType str, char * pStr, int size);
  117. bool EXPPLUS pxGetValue(AnyType dat, pxDate * pDat);
  118. bool EXPPLUS pxGetValue(AnyType tim, pxTime * pTim);
  119. bool EXPPLUS pxGetValue(AnyType tim, pxDateTime * pdt);
  120. bool EXPPLUS pxGetCurrency(AnyType nu, long double * pNu);
  121.  
  122. //
  123. // Get the Data from the Array or Record given the index.
  124. // Indexes START AT 0 (ie 0 based) not 1 based as in ObjectPAL.
  125. // Index zero of a record is the first item in the record, index 2
  126. // is the second and so on. The item that is return is a direct pointer
  127. // to the data (NULL is error occurred). You can use pxSetValue or
  128. // pxGetValue to retreive or set the value.
  129. //
  130.  
  131. AnyType EXPPLUS pxGetData(Array    ar , unsigned long int index);
  132. AnyType EXPPLUS pxGetData(Record   rec, unsigned long int index);
  133.  
  134.  
  135. //
  136. // Get the Data from the DynArray or Record given the name of
  137. // the DynArray key or Record field.
  138. //
  139.  
  140. AnyType EXPPLUS pxGetData(Record   rec, const char * name);
  141. AnyType EXPPLUS pxGetData(DynArray da , const char * name);
  142. bool    EXPPLUS pxSetData(DynArray da , const char * name, palDatum & data);
  143.  
  144. //
  145. // Get the number of items of the various items (for a String
  146. //    the number of items is the number of characters.
  147. //
  148.  
  149. long int   EXPPLUS pxGetCount(String str);
  150. long int   EXPPLUS pxGetCount(Array  ar);
  151. long int   EXPPLUS pxGetCount(Record rec);
  152.  
  153. long int   EXPPLUS pxGetSize(AnyType data);
  154.  
  155.  
  156. //
  157. //  Set the value of the ObjectPal data. Do any necessary conversion.
  158. //  Returns TRUE is successful, FALSE otherwise.
  159. //
  160. bool       EXPPLUS pxSetValue(AnyType    sm , int i);
  161. bool       EXPPLUS pxSetValue(AnyType    li , long l);
  162. bool       EXPPLUS pxSetValue(AnyType    nu , long double ld);
  163. bool       EXPPLUS pxSetValue(AnyType    str, const char * s);
  164. bool       EXPPLUS pxSetValue(AnyType    dat, pxDate * pDate);
  165. bool       EXPPLUS pxSetValue(AnyType    tim, pxTime * pTime);
  166. bool       EXPPLUS pxSetValue(AnyType    tim, pxDateTime * pDT);
  167. bool       EXPPLUS pxSetCurrency(AnyType cu , long double money);
  168.  
  169.  
  170. //
  171. //   The following routines allow you to have Object do something
  172. //   while you are in your C code. The idea is not to send the
  173. //   predeclared action (or menu ids) but send your own which
  174. //   you trap on. This allows the C routine to have ObjectPAL
  175. //   do things on its behave. Use global Records, DynArrays, or
  176. //   arrays to communicate info.
  177. //
  178. //   Issues a MENU!! event to the object. 
  179. //    (Actually it was supposed to issue an Action Event
  180. //     but since these functions are not supposed to be here
  181. //     they are not QAed and therefore this bug slipped by.
  182. //     kind of handy any way. You can still do the stuff you 
  183. //     could have with the action.)
  184. //
  185. //     pxAction(u16 action) issuses the action to self.
  186. //     pxAction(UIObject obj, u16 action) issuses the action
  187. //        to the specified UIObject. This is really the UIObject
  188. //        it is not the name of the object. 
  189. //     The return value is (eventInfo.errorCode() = NOERR) in other words,
  190. //     TRUE if no error, FALSE otherwise.
  191. //       
  192. //
  193.  
  194. bool       EXPPLUS pxAction(u16 action);
  195. bool       EXPPLUS pxAction(UIObject obj, u16 action);
  196.  
  197. //
  198. //   Posts an action event (a real Action event) to the object. 
  199. //     pxAction(u16 action) issuses the action to self.
  200. //     pxAction(UIObject obj, u16 action) issuses the action
  201. //        to the specified UIObject. This is really the UIObject
  202. //        it is not the name of the object. 
  203. //     The return value is (eventInfo.errorCode() = NOERR) in other words,
  204. //     TRUE if no error, FALSE otherwise.
  205. //       
  206. //
  207.  
  208. void       EXPPLUS pxPostAction(u16 action);
  209. void       EXPPLUS pxPostAction(UIObject obj, u16 action);
  210.  
  211. #endif
  212.  
  213.                             
  214.